package com.akrc.blog.mapper;

import com.akrc.blog.model.Post;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PostMapper {
	@Select("select * from post where id = ${id}")
	@Results({
			@Result(property = "id", column = "id"),
			@Result(property = "header_image", column = "header_image"),
			@Result(property = "title", column = "title"),
			@Result(property = "content", column = "content"),
			@Result(property = "category", column = "category"),
			@Result(property = "author", column = "author"),
			@Result(property = "slug", column = "slug"),
			@Result(property = "create_date", column = "create_date"),
			@Result(property = "visit", column = "visit")
	})
	Post getPost(Integer id);

	@Update("UPDATE post SET visit = visit + 1 WHERE id = ${id}")
	void updateCount(Integer id);

	@Select("SELECT * FROM post")
	List<Post> PostList (Integer pid);
}
